//
//  AppDelegate.m
//  MapEditor
//
//  Created by Eric on 3/3/12.
//  Copyright __MyCompanyName__ 2012. All rights reserved.
//

#import "AppDelegate.h"
#import "MEEditStageLayer.h"
#import "MEGLView.h"
#import "MEController.h"

@implementation MapEditorAppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    if (![MEController instance]) {
        MEController *windowCtrl = [[MEController alloc] initWithWindowNibName:@"MEWindow"];
        [windowCtrl showWindow:self];
    }   
}

- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *) theApplication
{
	return YES;
}

- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
    NSLog(@"application is asking to open %@",filename);
    MEController *windowCtrl = [[MEController alloc] initWithWindowNibName:@"MEWindow"];
    windowCtrl.dataFilePath = filename;
    [windowCtrl showWindow:self];
    
    return YES;
}

#pragma mark AppDelegate - IBActions

- (IBAction)toggleFullScreen: (id)sender
{
	CCDirectorMac *director = (CCDirectorMac*) [CCDirector sharedDirector];
	[director setFullScreen: ! [director isFullScreen] ];
}

@end
